<template>
  <div>
    <h2>添加</h2>
    <table class="table table-bordered">
      <tbody>
        <tr>
          <td>项目名称</td>
          <td>
            <input type="text" v-model="form.name" />
          </td>
        </tr>
        <tr>
          <td>项目编号</td>
          <td>
            <input type="text" v-model="form.bianhao" />
          </td>
        </tr>
        <tr>
          <td>服务人数</td>
          <td>
            <input type="text" v-model="form.hour" />
          </td>
        </tr>
        <tr>
          <td>服务时长</td>
          <td>
            <input type="text" v-model="form.people" />
          </td>
        </tr>
        <tr>
          <td>佣金</td>
          <td>
            <input type="text" v-model="form.money" />
          </td>
        </tr>
        <tr>
          <td>项目说明</td>
          <td>
            <textarea v-model="form.shouMing"> </textarea>
          </td>
        </tr>
        <tr>
          <td>说明</td>
          <td>
            <textarea v-model="form.zhuangTai"> </textarea>
          </td>
        </tr>
        <tr>
          <td>状态</td>
          <td>
            <input type="radio" v-model="form.start" value="1" />启用
            <input type="radio" v-model="form.start" value="0" />禁用
          </td>
        </tr>
        <tr>
          <td></td>
          <td>
            <button class="btn btn-primary" @click="Add">添加</button>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import axios from "axios";
import { ref, reactive, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router";

const router = useRouter();
const form = {
  id: 0,
  name: "",
  bianhao: 0,
  hour: "",
  people: "",
  money: "",
  shouMing: "",
  zhuangTai: "",
  start: 0,
  isDeleted: true
};

const Add=()=>{
    if (!form.name) {
        alert("项目名称不能为空！！");
        return;
    }
    if (!form.bianhao) {
        alert("项目编号不能为空！！");
        return;
    }
    if (!form.hour) {
        alert("服务时长不能为空！！");
        return;
    }
    if (!form.people) {
        alert("服务人数不能为空！！");
        return;
    }
    if (!form.money) {
        alert("佣金不能为空！！");
        return;
    }
    if (!form.shouMing) {
        alert("项目说明不能为空！！");
        return;
    }
    if (!form.start) {
        alert("状态不能为空！！");
        return;
    }

    axios.post("https://localhost:7189/api/shop/Add",form).then(res=>{
        if(res.data>0){
            alert("添加成功");
            router.push("/showshop");
        }
        else{
            alert("添加失败");
        }
    })





}


</script>

<style scoped></style>
